package com.franciscogarrido.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import com.franciscogarrido.model.criterios.NewArrivalCriterios;
import com.franciscogarrido.model.dto.NewArrivalDto;

public class NewArrivalsDao {

	private SqlSessionFactory sqlSessionFactory;

	public NewArrivalsDao() {
		sqlSessionFactory = MyBatisConnectionFactory.getSqlSessionFactory();
	}

	/**
	 * Delete an instance of Contact from the database.
	 * 
	 * @param id
	 *            primary key value of the instance to be deleted.
	 * @return
	 */
	public List<NewArrivalDto> getNewArrivals(NewArrivalCriterios criterios) {

		SqlSession session = sqlSessionFactory.openSession();

		try {
			List<NewArrivalDto> newArrivals = session.selectList(
					"NewArrival_SQL.getNewArrivals", criterios);
			session.commit();
			return newArrivals;
		} finally {
			session.close();
		}
	}
}